package com.bocai.dahuatech.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bocai.dahuatech.R;
import com.bocai.dahuatech.Bean.CityListBean;

public class CityListAdapter extends BaseAdapter {

    private CityListBean bean;
    private Context context;
    public CityListAdapter(Context context,CityListBean bean){
        this.context=context;
        this.bean=bean;
    }
    @Override
    public int getCount() {
        return bean.getContent().size();
    }

    @Override
    public Object getItem(int position) {
        return bean.getContent().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null)
        {
            holder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.citylist_item,null);
            holder.tvCity= (TextView) convertView.findViewById(R.id.tv_city_item);
            convertView.setTag(holder);

        }else
        {
            holder= (ViewHolder) convertView.getTag();
        }
        holder.tvCity.setText(bean.getContent().get(position).getFItemName());
        return convertView;
    }

    class ViewHolder{
        TextView tvCity;
    }
}
